/**
 * OSAmI: Open Source Ambient Intelligence
 * A simple publish/subscribe/dispatch API (based on multicast communications) for constrained devices.
 * Copyright (C) Lionel Debroux 2006 (as a TER/Magistere M1 student in the LSR-IMAG-ADELE team, for a demo in the H-Omega project)
 * Copyright (C) Lionel Debroux 2010 (as an engineer in the LCIS-INPG-CTSYS team, for a pre-demo in the FR part of the OSAMI project)
 * Contact: osami-general@osami-commons.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
 */

package fr.imag.adele.homega.impl.unicast;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * API used by the multicast manager.
 * Bundles representing devices register and unregister themselves on the multicast manager.
 */
public interface UnicastHandler {
	/**
	 * Register a listener of given topic.
	 */
	public void register(java.lang.String topic, int port, UnicastReceiver listener) throws IOException;

	/**
	 * Unregister a listener of given topic.
	 */
	public void unregister(java.lang.String topic, int port, UnicastReceiver listener) throws IOException;

	/**
	 * Shutdown this handler, terminate the underlying threads and release sockets.
	 */
	public void shutdown();

	/**
	 * Unregister all subscribers of given topic.
	 * Called upon thread termination.
	 */
	/*package*/ void unregisterAll(TopicInfo topic);

	/*package*/ void printMembers();

	/*package*/ void dispatch(DatagramSocket socket, DatagramPacket packet) throws IOException;
}
